import { defineConfig } from 'vite';
import uni from '@dcloudio/vite-plugin-uni';
import path from 'path';
import DefineOptions from 'unplugin-vue-define-options/vite';
import { codeInspectorPlugin } from 'code-inspector-plugin';

const dir = (url: string): string => path.resolve(__dirname, url);

// https://vitejs.dev/config/
export default defineConfig({
    resolve: {
        alias: {
            '@': dir('src'),
            '@mc': dir('src/modules/components'),
        },
    },
    plugins: [
        DefineOptions(),
        uni(),
        codeInspectorPlugin({
            bundler: 'vite',
        }),
    ],
    css: {
        preprocessorOptions: {
            scss: {
                additionalData: "@import '@/styles/variate.scss';@import '@/styles/theme.scss';",
            },
        },
    },
    server: {
        open: true,
        proxy: {
            '/api': {
                target: 'https://test.pi.xuexiaole.com',
                changeOrigin: true,
                pathRewrite: { '^/api': '' },
            },
        },
    },
});
